
; gives time in seconds
; (car (mktime (car (strptime "%Y-%m-%d %H:%M" "2017-12-12"))))
; 1513058400

; converts numeber to string
; (strftime "%c" (localtime 1513058400))
; "mar 12 dic 2017 00:00:00 CST"

; gives current time as time
; (localtime (current-time))
; ;#(30 47 11 8 10 117 3 311 0 21600 "CST")

; ; convers string to time
; (strptime "%c" (strftime "%c" (localtime 1513058400)))
; ;(#(0 0 0 12 11 117 2 345 -1 0 #f) . 28)
; (strptime "%c"  "mar 12 dic 2017 12:30:00 CST")
;(#(0 30 12 12 11 117 2 345 -1 0 #f) . 28)
;convuert current time to UTC
; (strftime "%c" (localtime (current-time) "UTC"))
;(countdown "2017-12-12 12:30")
; STRING-> STRING
(define (countdown end)
  (let ((end-secs (car (mktime (car (strptime "%Y-%m-%d %H:%M" end)))))
	(current-secs (car (mktime (car (strptime "%c" (strftime "%c" (localtime (current-time) "UTC"))))))))
    (format #f "~?" "~d Days ~d Hours ~d Minutes until next LGN" (seconds-to-time (- end-secs current-secs)))))
;(format #f "~a seconds left"  (- end-secs (current-time)))
;(format #t "~?" "~d hola  ~d" '(1 2))

(define (seconds-to-time seconds)
  (define (days-left time)
    (floor (/ time 86400)))
  (define (hours-left time)
    (floor (/ (remainder time 86400)
	      3600)))
  (define (minutes-left time)
    (floor (/ (remainder (remainder time 86400) 3600)
	      60)))

  (list (days-left seconds)
	(hours-left seconds)
	(minutes-left seconds)))
